package org.apache.nutch.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import cn.data.SysConf;

public class SysConfServlet extends HttpServlet
{
	private SysConf sysConf = null;
	@Override
	protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
	{
		// TODO Auto-generated method stub
		doPost(arg0, arg1);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
	{
		// TODO Auto-generated method stub
		WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(req.getSession().getServletContext());	
		if(ctx.containsBean("sysConf"))  
		{
			sysConf = (SysConf) ctx.getBean("sysConf");
			sysConf.setMaxdepth(req.getParameter("maxdepth"));
			sysConf.setMaxlinks(req.getParameter("maxlinks"));
		}
	}

}
